<template>
  <div class="contentbox">
    <div class="annexHeadTit">附件列表</div>
    <el-tabs class="annexTabs" stretch tab-position="left" v-model="annexTabs">
      <el-tab-pane
        v-for="(item, index) in attachmentsList"
        :label="item.fileName | handleSuffix"
        :key="item.id"
        :name="`annexOpinions${index}`"
      >
        <annex-opinions
          :ref="item.fileType"
          :file="item"
          :linkName="linkName"
          :projectId="projectId"
        ></annex-opinions>
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import annexOpinions from "./annexSub/annexOpinions";
export default {
  components: {
    annexOpinions
  },
  data() {
    return {
      annexTabs: `annexOpinions0`
    };
  },
  props: {
    attachmentsList: {
      type: Array,
      require: true,
      default: () => []
    },
    projectId: {
      type: Number,
      require: true
    },
    linkName: {
      type: String,
      require: true
    }
  },
  filters: {
    handleSuffix(fileName) {
      if (!fileName) return "";
      return fileName.indexOf(".") !== -1 ? fileName.split(".")[0] : "";
    }
  },
  created() {},
  methods: {
    exportAnnexOpinionByType(fileType) {
      if (this.$refs[fileType]) {
        this.$refs[fileType].getExport();
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.contentbox {
  position: relative;
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  // -webkit-align-items: center;
  // align-items: center;
  .annexHeadTit {
    color: #666666;
    font-size: 14px;
    background: #f9fafc;
    width: 160px;
    height: 36px;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
    padding-left: 20px;
    line-height: 36px;
  }
  .annexTabs {
    width: 100%;

    /deep/ .el-tabs__header {
      background: #f9fafc;
    }

    /deep/ .el-tabs__nav-wrap::after {
      width: 0;
    }

    /deep/ .el-tabs__header {
      width: 160px;
      padding-top: 36px;
      margin-right: 10px;

      /deep/ .el-tabs__item.is-active {
        background: #ebeff5;
      }

      /deep/ .el-tabs__item {
        text-align: left;
      }
      
    }
  }
}
</style>
